<template>
  <div>
    <center>
      <h1>八维采购平台</h1>

      <el-form ref="form" :model="form" label-width="120px" style="width: 20%">
        <el-form-item label="请输入账号">
          <el-input v-model="form.username"></el-input>
        </el-form-item>
        <el-form-item label="请输入密码">
          <el-input v-model="form.password"></el-input>
        </el-form-item>
      </el-form>
      <el-button type="primary" @click="login">登录</el-button>
    </center>
  </div>
</template>

<script>
import { login } from '@/api/userApi'
export default {
  data() {
    return {
      form: {

      }
    }
  },
  methods: {
    login() {
      login(this.form).then((res)=>{
        if(res.success){
          this.$message.success("登陆成功！")
          var token = res.data;
          sessionStorage.setItem("token", token);
          this.$router.push("/list");
        }else{
          this.$message.error(res.msg)
        }
      })
    }
  }
}
</script>

<style scoped>

</style>